<template>
  <div class="AddOrUpdate_main add_container column_three">
    <div class="main_main ">
      <el-form ref="form" :model="formData" :rules="rules" :inline="true">
        <el-tabs v-model="activeName">
          <el-tab-pane label="设备保养" name="first">
            <el-form-item label="保养工单号" prop="code">
              <CodeRuleInput v-if="!formData.planCode" :band-value.sync="formData.code" table-name="device_maintain_record" column-name="code" :is-edit="id" />
              <el-input v-else v-model="formData.code" placeholder="暂无" disabled />
            </el-form-item>
            <el-form-item label="保养计划单号">
              <el-input v-if="!id" v-model="formData.planCode" disabled placeholder="暂无" />
              <el-input v-else v-model="formData.planCode" placeholder="暂无" disabled />
            </el-form-item>
            <el-form-item label="保养设备" prop="bookId" class="clickChoose">

              <el-input v-if="!formData.id" v-model="formData.bookName" placeholder="请选择" readonly />
              <!--              <el-select v-if="!formData.planCode" v-model="formData.bookId" clearable filterable placeholder="请选择">-->
              <!--                <el-option-->
              <!--                  v-for="item in equipmentList"-->
              <!--                  :key="item.id"-->
              <!--                  :label="item.bookName"-->
              <!--                  :value="item.id"-->
              <!--                />-->
              <!--              </el-select>-->
              <a v-if="!formData.id" class="clickChoose_button" @click.prevent="chooseEquipments">
                <svg-icon icon-class="选择弹框" />
              </a>
              <el-input v-else v-model="formData.bookName" placeholder="暂无" disabled />
            </el-form-item>
            <el-form-item label="设备位置" prop="location">
              <el-input v-model="formData.location" placeholder="暂无" disabled />
            </el-form-item>
            <el-form-item label="保养级别" prop="level">
              <el-select v-model="formData.level" clearable filterable placeholder="请选择" @change="loadPeople">
                <el-option
                  v-for="item in maintenanceId1"
                  :key="item.level"
                  :label="item.label"
                  :value="item.level"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="计划保养时间" prop="planTime">

              <el-input v-if="formData.planCode" v-model="formData.planTime" placeholder="" disabled />
              <el-date-picker
                v-else
                v-model="formData.planTime"

                type="datetime"
                value-format="yyyy-MM-dd HH:mm"
                format="yyyy-MM-dd HH:mm"
                placeholder="请选择"
                :editable="false"
              />
            </el-form-item>
            <el-form-item label="班次">
              <DictSelect :band-value.sync="formData.shiftCode" dict-type="shiftCode" />
            </el-form-item>
            <el-form-item label="保养模板" prop="templateName" class="clickChoose">
              <el-input v-if="!formData.id" v-model="formData.templateName" placeholder="请选择" readonly />
              <a v-if="!formData.id" class="clickChoose_button" @click.prevent="chooseTemplates">
                <svg-icon icon-class="选择弹框" />
              </a>

              <el-input v-else v-model="formData.templateName" placeholder="暂无" disabled />
            </el-form-item>
            <el-form-item label="备注" class="double">
              <el-input
                v-model="formData.remark"
                type="textarea"
                maxlength="200"
                show-word-limit
                placeholder="请输入"
              />
            </el-form-item>
            <el-divider />
            <el-form-item label="保养人员" prop="checkPersonId" class="clickChoose">
              <el-input v-model="formData.checkPersonName" placeholder="请选择" readonly />
              <a class="clickChoose_button" @click.prevent="chooseTeamAndPeople">
                <svg-icon icon-class="选择弹框" />
              </a>
            </el-form-item>

            <el-form-item label="维保班组">
              <el-input v-model="formData.baseMaintenanceName" placeholder="暂无" disabled />
            </el-form-item>
            <el-form-item label="保养费用（元）">
              <el-input v-model="formData.maintainMoney" type="number" oninput="if(value<0)value=0" placeholder="请输入" />
              <!-- <el-input v-model="formData.maintainMoney" oninput="value=value.replace(/^0|[^0-9]/g,'')" placeholder="请输入" /> -->
            </el-form-item>
            <el-form-item label="保养完成时间" prop="completeTime">
              <el-date-picker
                v-model="formData.completeTime"

                type="datetime"
                value-format="yyyy-MM-dd HH:mm"
                format="yyyy-MM-dd HH:mm"
                placeholder="请选择"
                :editable="false"
              />
            </el-form-item>
            <el-form-item />
            <el-form-item />
            <div ref="table_container" class="table_container draggableTable addRow_table">
              <el-table
                ref="table"
                :data="tableData"
                stripe
                border
                row-key="id"
                style="width: 99.9%"
                :cell-class-name="cellClassName"
                :row-class-name="rowClassName"
              >
                <el-table-column type="expand">
                  <template slot-scope="props">
                    <el-form label-position="left" class="expand_container">
                      <el-form-item label="保养结果" class="expand_radio">
                        <el-radio v-model="props.row.result" :label="1"><svg-icon icon-class="勾" /></el-radio>
                        <el-radio v-model="props.row.result" :label="0"><svg-icon icon-class="叉" /></el-radio>
                      </el-form-item>
                      <el-form-item label="现场照片" class="expand_file file double">
                        <FileManageFull
                          :file-names.sync="props.row.docName"
                          :file-real-names.sync="props.row.docRealName"
                          :file-urls.sync="props.row.docUrl"
                          :row-index="props.$index"
                          @fileName="setFileName"
                        />
                      </el-form-item>
                      <el-form-item label="保养记录" class="double">
                        <el-input v-model="props.row.description" type="textarea" placeholder="请输入" />
                      </el-form-item>
                      <el-form-item label="备注" class="double">
                        <el-input
                          v-model="props.row.remark"
                          type="textarea"
                          maxlength="200"
                          show-word-limit
                          placeholder="请输入"
                        />
                      </el-form-item>
                    </el-form>
                  </template>
                </el-table-column>
                <el-table-column prop="sort" label="序号" width="70">
                  <template slot-scope="scope">
                    <div v-if="!scope.row.isAdd">{{ scope.row.sort }}</div>
                    <div v-else />
                  </template>
                </el-table-column>
                <el-table-column prop="name" label="保养项目">
                  <template slot-scope="scope">
                    <DivTextarea :row-value="scope.row.name" />
                  <!-- <el-input v-model="scope.row.name" style="margin:10px 0;" type="textarea" autosize readonly /> -->
                  </template>
                </el-table-column>
                <el-table-column prop="content" label="保养内容">
                  <template slot-scope="scope">
                    <DivTextarea :row-value="scope.row.content" />
                  <!-- <el-input v-model="scope.row.content" style="margin:10px 0;" type="textarea" autosize readonly /> -->
                  </template>
                </el-table-column>
                <el-table-column prop="way" label="保养方式">
                  <template slot-scope="scope">
                    <DivTextarea :row-value="scope.row.way" />
                  <!-- <el-input v-model="scope.row.way" style="margin:10px 0;" type="textarea" autosize readonly /> -->
                  </template>
                </el-table-column>
                <el-table-column prop="time" label="时间 ( S )" width="80">
                  <template slot-scope="scope">
                    <DivTextarea :row-value="scope.row.time" />
                  <!-- <el-input v-model="scope.row.time" style="margin:10px 0;" type="textarea" autosize readonly /> -->
                  </template>
                </el-table-column>
                <el-table-column prop="criterion" label="判断标准">
                  <template slot-scope="scope">
                    <DivTextarea :row-value="scope.row.criterion" />
                  <!-- <el-input v-model="scope.row.criterion" style="margin:10px 0;" type="textarea" autosize readonly /> -->
                  </template>
                </el-table-column>
                <el-table-column prop="time" label="至少上传张数" width="140">
                  <template slot-scope="scope">
                    <!-- <el-input v-model="scope.row.time" style="margin:10px 0;" type="textarea" autosize readonly /> -->
                    <DivTextarea :row-value="scope.row.minPage?scope.row.minPage+'':''" />
                  </template>
                </el-table-column>
                <el-table-column
                  label="附件"
                  min-width="120"
                >
                  <template slot-scope="scope">
                    <FileManage
                      :file-names.sync="scope.row.fileName"
                      :file-real-names.sync="scope.row.fileRealName"
                      :file-urls.sync="scope.row.fileUrl"
                      :readonly="true"
                    />
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </el-tab-pane>
          <el-tab-pane label="添加备件" name="second">
            <div class="formItem_header">
              <div class="formItem_header_operate">

                <a class="formItem_header_operate_item" @click="addRecord">
                  <svg-icon icon-class="新增" />
                  <div class="item_name">添加</div>
                </a>
                <a class="formItem_header_operate_item" @click="importSpareParts">
                  <svg-icon icon-class="导入" />
                  <div class="item_name">导入</div>
                </a>
                <a class="formItem_header_operate_item delete" @click="removeRow">
                  <svg-icon icon-class="删除" />
                  <div class="item_name">删除</div>
                </a>
              </div>
            </div>
            <div ref="table_container2" class="container-repair addRow_table">
              <el-table
                ref="table"
                :data="spareList"
                stripe
                border
                style="width: 99.9%"
                :header-cell-class-name="headerCellClassName"
                @selection-change="selectionChange1"
              >
                <el-table-column type="selection" align="center" width="50" />
                <el-table-column
                  prop="spareCode"
                  label="备件编码"
                  min-width="120"
                  show-overflow-tooltip
                />
                <el-table-column
                  prop="spareName"
                  label="备件名称"
                  min-width="100"
                  show-overflow-tooltip
                />
                <el-table-column
                  prop="spareModel"
                  label="规格型号"
                  min-width="100"
                  show-overflow-tooltip
                />
                <el-table-column
                  prop="numberUnitLabel"
                  label="备件单位"
                  min-width="100"
                />
                <el-table-column
                  prop="deviceSpareWarehouseName"
                  label="仓库"
                  min-width="100"
                />
                <el-table-column
                  prop="batch"
                  label="批号"
                  min-width="100"
                />
                <el-table-column
                  prop="inventoryNumber"
                  label="库存数量"
                  :min-width="SETTINGS.settings_decimalDigits_length"
                />
                <el-table-column
                  prop="useNumber"
                  label="使用数量"
                  :min-width="SETTINGS.settings_decimalDigits_length"
                >
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.useNumber" style="" placeholder="请输入" />
                  </template>
                </el-table-column>
                <el-table-column
                  v-if="isCheck"
                  prop="operate"
                  width="60"
                >
                  <!--                  <template slot-scope="scope">-->
                  <!--&lt;!&ndash;                    <el-button class="el-icon-remove" style="font-size: 25px;color: #ff0000;height: 100%;width: 100%;border: 0px;background-color: transparent" @click.native="removeRow(scope.row)" />&ndash;&gt;-->
                  <!--                    &lt;!&ndash;                    <el-button  class="el-icon-circle-plus" style="font-size: 25px;color: green;height: 100%;width: 100%;border: 0px;background-color: transparent" @click.native="addRow(scope.row)" />&ndash;&gt;-->
                  <!--                  </template>-->
                </el-table-column>
              </el-table>
            </div>
          </el-tab-pane>
        </el-tabs>
      </el-form>
    </div>
    <div class="main_bottom">
      <el-button type="cancel" @click.stop="cancel">取消</el-button>
      <el-button v-if="formData.status!==2" @click.stop="save">保存</el-button>
      <el-button @click.stop="onSubmit">提交</el-button>
    </div>
  </div>
</template>

<script>
import DivTextarea from '@/components/JLink/common/DivTextarea.vue'
import { addOrUpdate, getInfo } from '@/api/equipmentManage/equipmentMaintain/maintainRecord'
import { importMethod } from '@/api/equipmentManage/sparePart/outWarehouse'
import { list } from '@/api/equipmentManage/equipmentMaintain/maintainTemplate'
import { list as getEquipmentList } from '@/api/equipmentManage/baseInfo/equipmentInfo'
import { list as getUserTeam, list as maintenanceTeamList } from '@/api/equipmentManage/baseInfo/maintenanceTeam'
import { personnellist } from '@/api/equipmentManage/equipmentRepair/equipmentReportRepair'
import chooseTemplate from '../../equipmentMaintain/maintainTemplate/searchTemplate.vue'
import chooseEquipment from '../../baseInfo/equipmentInfo/chooseEquiment.vue'
import addRecord from '../../sparePartsManagement/sparePartsCollocation/chooseSpareParts.vue'
import moment from 'moment'
import ImportData from '@/components/JLink/common/ImportData'
import chooseTeam from '@/views/equipmentManage/baseInfo/maintenanceTeam/chooseTeam.vue'
export default {
  name: 'AddOrUpdate',
  components: {
    DivTextarea
  },
  props: {
    layerid: {},
    id: {},
    defaultValue: {},
    isAdd: {}
  },
  data() {
    return {
      pageId: '保养备件', // 页面唯一标识
      formData: {
        id: undefined,
        code: undefined,
        planCode: undefined,
        bookId: undefined,
        bookName: undefined,
        location: undefined,
        checkPersonId: undefined,
        level: undefined,
        levelName: undefined,
        outFormCode: undefined,
        planTime: undefined,
        templateName: undefined,
        templateId: '',
        completeTime: '',
        status: '',
        remark: undefined,
        checkPersonName: undefined,
        shiftCode: undefined,
        maintenanceName: undefined,
        baseMaintenanceName: undefined,
        maintenanceId: undefined,
        planId: undefined,
        isSubmit: 0,
        maintainMoney: '',
        spareList: [],
        detailList: []
      },
      tableHeight: '100',
      tableHeight2: '5000',
      equipmentList: [],
      templateList: [],
      teamList: [],
      tableData: [],
      peopleList: [],
      num: 1,
      type: '',
      activeName: 'first',
      spareList: [],
      roleOptions: [],
      selectionsAll1: [],
      maintenanceId1: [
        { label: '一级保养', level: 1 },
        { label: '二级保养', level: 2 },
        { label: '三级保养', level: 3 }
      ],
      rules: {
        code: [
          { required: true, message: '保养工单号不能为空', trigger: 'blur' }
        ],
        bookId: [
          { required: true, message: '保养设备不能为空', trigger: 'change' }
        ],
        templateId: [
          { required: true, message: '保养模版不能为空', trigger: 'change' }
        ],
        templateName: [
          { required: true, message: '保养模版不能为空', trigger: 'change' }
        ],
        level: [
          { required: true, message: '保养级别不能为空', trigger: 'change' }
        ],
        planTime: [
          { required: true, message: '计划保养时间不能为空', trigger: 'change' }
        ],
        completeTime: [
          { required: true, message: '保养完成时间不能为空', trigger: 'change' }
        ],
        taskMode: [
          { required: true, message: '任务启动方式不能为空', trigger: 'change' }
        ],
        period: [
          { required: true, message: '保养周期不能为空', trigger: 'change' }
        ],
        periodUnit: [
          { required: true, message: '周期单位不能为空', trigger: 'change' }
        ],
        checkPersonId: [
          { required: true, message: '保养人员不能为空', trigger: 'change' }
        ]
      }
    }
  },
  watch: {
  },
  created() {
    if (!this.id) { // 没有id就是新增
      // Object.keys(this.defaultValue).forEach(key => { // 给右边数据赋值
      //   this.formData[key] = this.defaultValue[key]
      // })
      this.formData.completeTime = moment(new Date()).format('YYYY-MM-DD HH:mm')

      // 获取当前登录人员是否只有一个维保班组
      getUserTeam({
        pageSize: 0,
        status: '1',
        userId: this.$store.state.user.userId
      }).then(res => {
        console.log('res.data', res.data)
        if (res && res.data.length == 1) {
          const row = res.data[0]
          this.formData.checkPersonId = this.$store.state.user.userId
          this.formData.checkPersonName = this.$store.state.user.userName
          this.formData.maintenanceId = row.id
          this.formData.maintenanceName = row.name
          this.formData.baseMaintenanceName = row.name
        }
      })
    } else { // 有id就是编辑
      this.getInfo()
      this.formData.id = this.id
    }
  },
  mounted() {
    // this.getList()
    // this.loadPeoples()
    // this.loadTeam()
  },
  methods: {
    headerCellClassName(data) {
      if (['useNumber'].indexOf(data.column.property) != -1) {
        return 'column_bt'
      }
    },
    selectionChange1(rows) {
      this.selectionsAll1 = rows
    },
    addRecord() { // 打开选择备件
      this.$layer.iframe({// 弹框
        content: {
          content: addRecord, // 传递的组件对象
          parent: this, // 当前的vue对象
          data: {
            defaultValue: {
              parentId: 0,
              parentName: '根目录'
            },
            selectedRow: this.spareList
          }// props
        },
        area: ['1320px', '700px'],
        title: '选择备件信息', // 标题
        shadeClose: false // 点击遮罩是否关闭
      })
    },
    cellClassName(data) {
      if (data.column.property == 'operate') {
        if (data.rowIndex % 2 == 0) { // 单数行
          return 'fixed one'
        } else { // 双数行
          return 'fixed two'
        }
      }
    },
    rowClassName({ row, rowIndex }) {
      if (rowIndex == this.formData.spareList.length - 1) {
        return 'addRow'
      }
    },
    removeRow(row) { // 删除行
      this.selectionsAll1.forEach(item => {
        this.spareList.splice(this.spareList.indexOf(item), 1)
      })
    },
    getInfo() {
      getInfo(this.id).then(res => {
        Object.keys(this.formData).forEach(key => { // 给右边数据赋值
          this.formData[key] = res.data[key] || ''
        })
        this.spareList = res.data.spareList
        this.tableData = res.data.detailList
        this.formData.status = res.data.status
        if (!this.formData.checkPersonId) {
          this.formData.checkPersonId = this.$store.state.user.userId
        }
      })
    },
    getList() {
      list().then(res => {
        this.templateList = res.data
      })
      getEquipmentList({ status: 1 }).then(res => {
        this.equipmentList = res.data
        res.data.forEach(item => {
          this.formData.location = item.location
        })
      })
    },
    // 选择物料后从弹窗取出来的数据
    addMaterial(data) {
      this.spareList = data
    },
    // 根据保养人员id查询维保班组
    searchTeam(e) {
      this.peopleList.forEach(item => {
        if (item.userId == e) {
          this.formData.maintenanceId = item.maintenanceId
        }
      })
    },
    // 加载维保班组数据
    loadTeam() {
      maintenanceTeamList().then(res => {
        this.teamList = res.data
      })
    },

    // 选择维保班组和人员
    chooseTeamAndPeople() {
      this.$layer.iframe({// 弹框
        content: {
          content: chooseTeam, // 传递的组件对象
          parent: this, // 当前的vue对象
          data: {
            userId: this.formData.checkPersonId ? this.formData.checkPersonId : '',
            teamId: this.formData.maintenanceId ? this.formData.maintenanceId : ''
          }// props
        },
        area: ['1320px', '600px'],
        title: '选择保养人员', // 标题
        shadeClose: false // 点击遮罩是否关闭
      })
    },

    // 选择人员和班组返回id
    showTeamAndPeople(teamId, row, peopleId, num) {
      this.formData.checkPersonId = row.userId
      this.formData.checkPersonName = row.realName
      this.formData.maintenanceId = row.maintenanceId
      this.formData.maintenanceName = row.maintenanceName
      this.formData.baseMaintenanceName = row.maintenanceName
    },
    // 加载保养人员数据
    loadPeople() {
      this.formData.planCode = ''
      personnellist({
        maintenanceId: this.formData.maintenanceId,
        status: 1,
        maintenanceStatus: 1
      }).then(res => {
        this.peopleList = res.data
      })
    },
    // 加载保养人员数据
    loadPeoples() {
      personnellist({
        maintenanceId: this.formData.maintenanceId,
        status: 1,
        maintenanceStatus: 1
      }).then(res => {
        this.peopleList = res.data
        this.peopleList.forEach(ele => {
          if (ele.userId == this.$store.state.user.uId) {
            this.formData.checkPersonId = ele.userId
            this.formData.checkPersonName = ele.realName
            this.formData.maintenanceId = ele.maintenanceId
            this.formData.maintenanceName = ele.maintenanceName
            this.formData.baseMaintenanceName = ele.maintenanceName
          }
        })
      })
    },
    // 选择保养模板
    chooseTemplates() {
      this.$layer.iframe({// 弹框
        content: {
          content: chooseTemplate, // 传递的组件对象
          parent: this, // 当前的vue对象
          data: {
            id: this.formData.templateId ? this.formData.templateId : '',
            name: this.formData.templateName ? this.formData.templateName : ''
          }// props
        },
        area: ['1320px', '700px'],
        title: '选择保养模版', // 标题
        shadeClose: false // 点击遮罩是否关闭
      })
    },
    // 选择保养设备
    chooseEquipments() {
      this.$layer.iframe({// 弹框
        content: {
          content: chooseEquipment, // 传递的组件对象
          parent: this, // 当前的vue对象
          data: {
            bookId: this.formData.bookId ? this.formData.bookId : ''
          }// props
        },
        area: ['1320px', '700px'],
        title: '选择保养设备', // 标题
        shadeClose: false // 点击遮罩是否关闭
      })
    },
    // 提交
    onSubmit() {
      if (this.spareList.filter(item => !item.useNumber).length > 0) {
        this.$message.warning('使用数量不能为空')
        return
      } else if (this.spareList.filter(item => item.useNumber && !this.SETTINGS.reg_no_zero.test(item.useNumber)).length > 0) {
        this.$message.warning('使用数量输入不正确')
        return
      } else if (this.spareList.filter(item => item.useNumber && Number(item.useNumber) > Number(item.inventoryNumber)).length > 0) {
        this.$message.warning('使用数量不能大于库存数量')
        return
      } else if (this.tableData.filter(item => !item.result && item.result != 0).length > 0) {
        this.$message.warning('保养项目中保养结果不能为空')
        return
      } else if (this.tableData.filter(item => (item.docRealName ? item.docRealName.split(',').length : 0) < item.minPage).length > 0) {
        const obj = this.tableData.filter(item => (item.docRealName ? item.docRealName.split(',').length : 0) < item.minPage)[0]
        this.$message({
          message: `保养项目${obj.name}的现场照片张数不能少于${obj.minPage}张`,
          type: 'warning'
        })
        return
      }
      this.type = 'submit'
      this.$refs['form'].validate(valid => {
        if (valid) {
          this.spareList.forEach(item => {
            if (item.isOldList !== true) {
              item.id = null
            }
          })
          this.formData.detailList = this.$deepClone(this.tableData)
          this.formData.detailList.forEach(ele => {
            delete ele.id
          })
          this.formData.id = this.id
          this.formData.spareList = this.$deepClone(this.spareList)
          this.formData.isSubmit = 1
          addOrUpdate(this.formData).then(res => {
            this.$message({
              message: res.msg,
              type: 'success'
            })
            this.$layer.close(this.layerid) // 关闭弹框
            this.$parent.getList() // 调用父组件的刷新方法
          })
        } else {
          this.activeName = 'first'
        }
      })
    },
    // 保存
    save() {
      let tag = true
      this.$refs['form'].validateField(['code', 'bookId', 'templateId', 'templateName', 'level', 'planTime', 'checkPersonId'], (valid) => {
        if (tag && valid) {
          this.activeName = 'first'
          tag = false
        }
      })
      if (tag) {
        // if (this.spareList.filter(item => !item.useNumber > item.inventoryNumber).length > 0) {
        //   this.$message.warning('使用数量不能大于库存数量')
        //   return
        // } else
        if (this.spareList.filter(item => item.useNumber && !this.SETTINGS.reg_no_zero.test(item.useNumber)).length > 0) {
          this.$message.warning('使用数量输入不正确')
          return
        } else if (this.spareList.filter(item => item.useNumber && Number(item.useNumber) > Number(item.inventoryNumber)).length > 0) {
          this.$message.warning('使用数量不能大于库存数量')
          return
        }
        this.spareList.forEach(item => {
          if (item.isOldList !== true) {
            item.id = null
          }
        })
        this.formData.detailList = this.$deepClone(this.tableData)
        this.formData.detailList.forEach(ele => {
          delete ele.id
        })
        this.formData.id = this.id
        this.formData.spareList = this.$deepClone(this.spareList)
        this.formData.isSubmit = 0
        addOrUpdate(this.formData).then(res => {
          this.$message({
            message: res.msg,
            type: 'success'
          })
          this.$layer.close(this.layerid) // 关闭弹框
          this.$parent.getList() // 调用父组件的刷新方法
        })
      }
    },
    cancel() {
      this.$layer.close(this.layerid)// 关闭弹框
    },
    setFileName(...data) {
      const cacheTableData = this.$deepClone(this.tableData)
      cacheTableData[data[3]].docName = data[0]
      cacheTableData[data[3]].docRealName = data[1]
      cacheTableData[data[3]].docUrl = data[2]
      this.tableData = cacheTableData
    },
    // 获取保养模版数据
    showTemplate(data, name, id) {
      data.forEach(ele => {
        ele['itemId'] = ele.id
      })
      this.tableData = data
      this.formData.templateId = id
      this.formData.templateName = name
      // this.formData.remark = remark
      this.getList()
    },
    // 获取保养设备id
    showEquipment(data) {
      this.formData.bookId = data.id
      this.formData.bookName = data.name
      this.formData.location = data.location
    },
    importSpareParts() { // 导入备件物料
      this.$layer.iframe({// 弹框
        content: {
          content: ImportData, // 传递的组件对象
          parent: this, // 当前的vue对象
          data: {}// props
        },
        area: ['440px', '250px'],
        title: '导入数据', // 标题
        shadeClose: false // 点击遮罩是否关闭
      })
    },
    importMethod(files) { // 导入接口
      importMethod(files).then(res => {
        if (res.data) {
          this.spareList = []
          res.data.forEach(item => {
            item.batchInventoryId = item.batchId
            if (Number(item.useNumber) > Number(item.batchInventoryNumber)) {
              this.$message.warning('导入的数据中存在出库数量大于库存数量的数据,请修改后重新导入')
              return false
            } else {
              this.spareList.push(item)
            }
          })
        }
      })
    }
  }
}
</script>

<style lang="less" scoped>
/deep/.el-form-item__label {
  width: 140px !important;
}
//一姐让注掉的
// /deep/ .el-textarea__inner{
//   border: none !important;
//   background: none;
//   overflow: hidden;
// }
/deep/ .accessory{
  color: #387bfc;
}
.main_main{
  padding-top: 0px;
  .formItem_header{
    justify-content: flex-end;
    align-items: flex-start;
    height: 40px;
  }
  .form_padding{
    display: flex;
    flex-wrap: wrap;

    /deep/ .el-form-item{
      margin-right: 0px;
    }
  }
  /deep/ .el-form{
    height: 100%;
  }
}
.expand_radio{
  /deep/ .el-form-item__content{
    text-align: left;
  }
}
.expand_container{
  .el-form-item{
    margin-bottom: 10px;
  }

}
/deep/ .el-table {
  height: 100% !important;
}
/deep/ .el-table th.el-table__cell>.cell{
  position:unset;
}
/deep/ .el-tabs__header{
  width: 100% !important;
  position: absolute;
  z-index: 99999;
}
/deep/ .el-tabs__content{
  margin-top: 50px;
}
.table_container{
  //margin-bottom: 70px;
}
.expand_radio{
  padding-top: 20px;
}
/deep/.is-scrolling-none {
  margin-bottom: 8px !important;
}
</style>
